class Solution {
public:
    void Inorder(vector<int>& v,TreeNode* root,stack<TreeNode*>& st)
    {
        if(root == nullptr)
            return;
        TreeNode* cur = root;
        while(cur || !st.empty())
        {
            while(cur)
            {
                st.push(cur);
                cur = cur->left;
            }
            TreeNode* top = st.top();
            st.pop();
            v.push_back(top->val);
            cur = top->right;
        }
    }
    vector<int> inorderTraversal(TreeNode* root) {
        vector<int> v;
        stack<TreeNode*> st;
        if(root == nullptr)
            return v;
        Inorder(v,root,st);
        return v;
    }
};